import Vue from 'vue'
import App from './App.vue'
import router from './router'

import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import axios from "axios";

Vue.config.productionTip = false
Vue.use(ElementUI);
//全局配置
axios.defaults.baseURL = 'http://localhost:8082'
// 添加Axios请求拦截器,设置请求头，设置token
axios.interceptors.request.use(config=>{
  if(store.state.token){
    config.headers["Authorization"]=store.state.token;
  }
  return config;
},function (error) {
  console.log(error)
});
//添加Axios响应拦截器
axios.interceptors.response.use(function (response){
  return response.data;
},function (error) {
  return Promise.reject(error);
})


new Vue({
  router,
  store,
  render: function (h) { return h(App) }
}).$mount('#app')
